package com.zsp.comic.service.impl;

import com.zsp.comic.dao.FriendDao;
import com.zsp.comic.entity.Friend;
import com.zsp.comic.service.FriendService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author gan
 * @create 2021-01-16 20:01
 */
@Service
public class FriendServiceImpl implements FriendService {

    @Resource
    private FriendDao friendDao;

    @Override
    public List<Friend> getAllFriend() {
        return friendDao.getAllFriend();
    }

    @Override
    public Friend getFriendById(Integer id) {
        return friendDao.getFriendById(id);
    }

    @Override
    public List<Friend> getFriendByName(String name) {
        return friendDao.getFriendByName(name);
    }

    @Override
    public List<Friend> getAllFriendWithAdminAuthority() {
        return friendDao.getAllFriendWithAdminAuthority();
    }

    @Override
    public Friend getFriendByIdWithAdminAuthority(Integer id) {
        return friendDao.getFriendByIdWithAdminAuthority(id);
    }

    @Override
    public List<Friend> getFriendByNameWithAdminAuthority(String name) {
        return friendDao.getFriendByNameWithAdminAuthority(name);
    }

    @Override
    public boolean addFriend(Friend friend) {
        friend.setJoinTime(new Date());
        return friendDao.addFriend(friend) > 0;
    }

    @Override
    public boolean updateFriend(Friend friend) {
        return friendDao.updateFriend(friend) > 0;
    }

    @Override
    public boolean deleteFriend(Integer id) {
        return friendDao.deleteFriend(id) > 0;
    }
}
